#include "graphsupport/graph/operation/CompoundGraphOperation.h"

IGraphOperationPtr CompoundGraphOperation::createOperation( int count, ... )
{
	CompoundGraphOperation * result = new CompoundGraphOperation();
	IGraphOperationPtr resultWrap = IGraphOperationPtr( result );

	va_list subOperations;
	va_start( subOperations, count );

	for ( int i = 0; i < count; i++ )
	{
		IGraphOperation * subOperation = va_arg( subOperations, IGraphOperation * );
		result->addSubOperation( IGraphOperationPtr( subOperation ) );
	}

	va_end( subOperations );

	return resultWrap;
}

CompoundGraphOperation::CompoundGraphOperation()
{
}

void CompoundGraphOperation::applyTo( Graph & graph, IOperationSettings & genSettings )
{
	for ( IGraphOperationPtrVec::iterator it = suboperations.begin();
		it != suboperations.end(); ++it )
	{
		( * it )->applyTo( graph, genSettings );
	}
}

void CompoundGraphOperation::addSubOperation( const IGraphOperationPtr & subOperation )
{
	suboperations.push_back( subOperation );
}
